Skip to content

develop - #167

Merged
ienaga merged 8 commits into
mainfrom
develop
Nov 28, 2026
Merged

ienaga merged 8 commits into
mainfrom
develop

Conversation

@ienaga

@ienaga ienaga commented Nov 28, 2026

Copy link
Copy Markdown
Member

No description provided.

ienaga and others added 8 commits November 28, 2026 18:54
The desktop package ships the game's HTML/JS/assets as plain files next to the
ASAR, so they could be edited in place. The builder now records the SHA-256 of
every shipped game file (integrity.json, inside the ASAR) and the host checks
each file against it before serving it. A file that was changed or added shows
an error and quits.

The bytes that were checked are the bytes that are served, so a file cannot be
swapped between the check and the read.
… bypassed

The check of the game files lives inside the ASAR, so the ASAR has to be
protected too. Flip the Electron fuses on the packaged runtime:

- validate the ASAR against the hash the packager embeds in the executable
  (macOS and Windows; Electron has no such validation on Linux)
- load the app only from the ASAR
- ignore ELECTRON_RUN_AS_NODE, NODE_OPTIONS and the inspect switches

Verified on Windows: a patched ASAR does not start, a modified game file shows
the error, the original package runs. Not yet run on macOS (the fuses are
flipped before signing, with the ad-hoc signature reset on Apple silicon).
…vTools)

The developer tools let anyone read and change the running game. They are now
disabled in the window unless electron.config.json sets "devTools": true, which
also adds the usual shortcut (F12 or Ctrl/Cmd+Shift+I; there is no application
menu to carry it). Meant for a development config file
(NEXT2D_ELECTRON_CONFIG_FILE), not for builds that are distributed.
The native host now checks the game's script files (.js .mjs .html .json
.wasm) against SHA-256 hashes recorded at build time:

- platform/AssetIntegrity.h (header only): SHA-256, the list of hashes and the
  check. A listed file must match; a script that is not listed is not read.
  Media files are not checked, so nothing is hashed on their load path.
- AssetLoader (ReadBinary / ReadText / OpenStream / entry module),
  V8Runtime::LoadModule and the host scripts (bootstrap.js) go through it.
- Host core API: next2d_host_set_asset_integrity(manifest), called before
  next2d_host_create. Without it nothing is checked (as before).
- Xbox: the builder writes the hashes of the embedded scripts into
  src/AssetIntegrityManifest.h, so they are compiled into the executable.

Unit test: tests/integrity_test.cpp (SHA-256 test vectors and the rules), added
to CI and check_local.sh. The Xbox executable itself (main.cpp) is not built
here; it is covered by the Xbox CI build.
…ot yet run on a device)

After `cap sync`, record the SHA-256 of the scripts in the native project and
add native code that verifies them when the app starts:

- Android: a ContentProvider (app.next2d.integrity.Next2DAssetIntegrity) runs
  before the app and compares assets/public and the Capacitor config files with
  hashes compiled into a generated class (kept out of git by a local
  .gitignore). One <provider> is added to AndroidManifest.xml.
- iOS: a block appended to AppDelegate.swift, called first in
  didFinishLaunchingWithOptions, compares the bundle with
  public/next2d-integrity.txt.
- `cap run` (preview) writes an empty list so development runs are not blocked.

The generators are covered by unit tests, and the Android path runs in the
existing `cap sync` test. The generated Java and Swift have NOT been compiled or
run: this machine has no Android SDK and no macOS. Verify on a device before
merging.
capacitor: check the packaged scripts at launch on Android and iOS (n…
@ienaga
ienaga merged commit 4f578b9 into main Nov 28, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant